<template>
  <div>
      <van-field v-model="name" label="名称" placeholder="请输入用户名" id="name"/>
      <van-button @click="add" id="add">修改</van-button>
  </div>
</template>

<script>
export default {
    data(){
        return{
            id:this.$route.query.id,
            name:''
        }
    },
    methods:{
        getCate(){
            this.axios.get('getCateByid?id='+this.id).then(res=>{
                this.name = res.data.cate.name
            })
        },
        add(){
            this.axios.post('cateM',{'name':this.name,'id':this.id}).then(res=>{
                alert('修改成功')
                this.$router.go(-1)
            })
        }
    },
    mounted(){
        this.getCate()
    }
}
</script>

<style>

</style>